<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const obj = {
            a: 1,
            b: '123',
            bb: {
                g: '22'
            },
            cc: [1, 2, 3, 4, 5],
            abc: function () {
                console.log(1);
            }
        }
        const newObj = {}
        function deepcopy(obj, newObj) {
            for (const key in obj) {
                if (typeof obj[key] === Function) {
                    newObj[key] = obj[key]
                } else if (typeof obj[key] === Array) {
                    newObj[key] = []
                    deepcopy(obj[key], newObj[key])
                } else if (typeof obj[key] === Object) {
                    newObj[key] = {}
                    deepcopy(obj[key], newObj[key])
                } else {
                    newObj[key] = obj[key]
                }
            }
        }
        deepcopy(obj, newObj)
        newObj.abc()
    </script>
</body>

</html>